package com.jr.dao.impl;

import com.jr.dao.BaseDataDao;
import com.jr.entity.BaseData;
import com.jr.util.DAO;

/**
 * @Function：
 * @Author 梁明哲
 * @Email 424577090@qq.com
 * @Package com.jr.dao.impl
 * @Project InvoiceManage
 * @Date 2023-02-20 15:07:03
 */
public class BaseDataDaoImpl extends DAO<BaseData> implements BaseDataDao {
    /**
     * 根据公司id查询相关信息
     *
     * @param enterpriseId 公司id
     * @return
     * @throws Exception sql语句问题
     */
    @Override
    public BaseData findAllByEnterpriseId(Integer enterpriseId) throws Exception {
        String sql = "SELECT title,tax_no AS taxNo,bank_name AS bankName,bank_account AS bankAccount,phone,address FROM base_data WHERE enterprise_id=?";
        return get(sql, enterpriseId);
    }

    /**
     * 根据公司id保存数据
     *
     * @param baseData 对象
     * @return
     * @throws Exception
     */
    @Override
    public Integer saveBaseData(BaseData baseData) throws Exception {
        String sql = "UPDATE base_data set bank_name = ?,bank_account=?,phone = ?,address=? WHERE enterprise_id=?";
        return update(sql,baseData.getBankName(),baseData.getBankAccount(),baseData.getPhone(),baseData.getAddress(),baseData.getEnterpriseId());
    }

}







